#include <linux/init.h>
#include <linux/module.h>
#include <linux/fs.h>
#include <linux/cdev.h>

MODULE_LICENSE("GPL");

static struct cdev ledCdev;
static dev_t devt;

int led_open(struct inode* inode, struct file* filePtr)
{
    printk("enter %s\n", __func__);
	return 0;
}

int led_release(struct inode* inode, struct file* filePtr)
{
    printk("enter %s\n", __func__);
	return 0;
}

ssize_t led_read(struct file* filePtr, char __user* buf, size_t len, loff_t* offset)
{
    printk("enter %s\n", __func__);
	return 0;
}

ssize_t led_write(struct file* filePtr, const char __user* buf, size_t len, loff_t* offset)
{
    printk("enter %s\n", __func__);
	return 0;
}

struct file_operations ledFops =
{
    .open = led_open,
    .release = led_release,
    .read = led_read,
    .write = led_write
};

int __init led_drv_init(void)
{
    alloc_chrdev_region(&devt, 100, 1, "leds");
    cdev_init(&ledCdev, &ledFops);
    cdev_add(&ledCdev, devt, 1);
    return 0;
}

void __exit led_drv_exit(void)
{
    cdev_del(&ledCdev);
    unregister_chrdev_region(devt, 1);
}

module_init(led_drv_init);
module_exit(led_drv_exit);
